import { BaseEntity } from "src/baseEntity";
import { Column, Entity, ManyToOne } from "typeorm";
import { V2ApplyWorkflow } from "./v2.apply.workflow.entity";
import { V2Apply } from "./v2.apply.entity";
import { UserSys } from "src/user/userSys.entity";
import { System } from "src/system/system.entity";

export enum ApplyUserStatus {
    待审批 = "待审批",
    已通过 = "已通过",
    拒绝申请 = "拒绝申请"
}

@Entity("v2_apply_log")
export class V2ApplyLog extends BaseEntity {
    @ManyToOne(() => System)
    system: System

    @ManyToOne(() => V2ApplyWorkflow)
    workflow: V2ApplyWorkflow

    @ManyToOne(() => V2Apply, { onDelete: "SET NULL" })
    apply: V2Apply

    @ManyToOne(() => UserSys)
    user: UserSys

    @Column()
    name: string

    @Column({
        default: "{}"
    })
    data: string

    @ManyToOne(() => UserSys)
    workUser: UserSys

    @Column({
        enum: ApplyUserStatus,
        type: "enum",
        default: ApplyUserStatus.待审批
    })
    status: ApplyUserStatus

    @Column({ nullable: true })
    comment: string
}